colorAdminApp.controller('passwordUpdateForExpiredController', function($scope,$rootScope,$http,$state,$stateParams,modalService,passwordService,loginService) {
	
	    $scope.username=$stateParams.username;
	   
	    $scope.orinPassword="";
	    $scope.newPassword="";
	    $scope.confirmNewPassword="";
	    
	    $scope.checkNewPassword=function(){
	    	passwordService.checkNewPassword($scope.newPassword);
	    }
	    
	    $scope.checkConfirmNewPassword=function(){
	     	passwordService.checkConfirmNewPassword($scope.newPassword,$scope.confirmNewPassword);
	    }
	 
		$scope.save=function(){
			if(passwordService.checkNewPassword($scope.newPassword)==false){
				return;
			}
			if(passwordService.checkConfirmNewPassword($scope.newPassword,$scope.confirmNewPassword)==false){
				return;
			}
			var entity={"username":$scope.username,"newPassword":$scope.confirmNewPassword,"orinPassword":$scope.orinPassword};
			
			$http.post('core/user/updatePasswordForExpired.htm',{params:entity}).success(function(data, status, headers, config) {
			    
				modalService.showAlertModal('注意',data.message);
				
				if(data.status==1){//如果修改成功就自动登录
					loginService.login($scope.username,$scope.confirmNewPassword,$scope,$http,$state);
				}
				
			}).error(function(data, status, headers, config) {
		    	alert(data);
	        });  
		}
	
});
